//
//  InterstitialViewController.m
//  HZZFAdSDK_Example
//
//  Copyright © 2025 早范. All rights reserved.
//

#import "InterstitialViewController.h"
#import <HZZFAdSDK/HZZFAdSDKInterstitialAd.h>
@interface InterstitialViewController ()<HZZFAdSDKInterstitialAdDelegate>
@property (nonatomic) HZZFAdSDKInterstitialAd *interstitialAd;
@end

@implementation InterstitialViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    self.title = @"插屏";
    CGFloat width = (self.view.frame.size.width - 150) / 2;
    self.view.backgroundColor = [UIColor whiteColor];
    UIButton *btn = [UIButton buttonWithType:UIButtonTypeCustom];
    btn.frame = CGRectMake(width, 100, 150, 40);
    
    [btn setTitleColor:[UIColor whiteColor] forState:UIControlStateNormal];
    btn.backgroundColor = [UIColor orangeColor];
    btn.layer.cornerRadius = 20;
    [self.view addSubview:btn];
    [btn setTitle:@"显示广告" forState:UIControlStateNormal];
//    [btn setTitleColor:[UIColor blackColor] forState:0];
    [btn addTarget:self action:@selector(innerLoadInterstitialAd) forControlEvents:UIControlEventTouchUpInside];
}
- (void) innerLoadInterstitialAd {
    if (self.interstitialAd) {
        [self.interstitialAd show];
        return;
    }
    
    self.interstitialAd = [[HZZFAdSDKInterstitialAd alloc]init];
    self.interstitialAd.delegate = self;
    self.interstitialAd.controller = self;
    self.interstitialAd.posId = @"13945365";
    [self.interstitialAd loadAdData];
    
}

#pragma mark - HZZFAdSDKInterstitialAdDelegate
/**
 HZZFAdSDKIntertitialAd请求成功回调
 
 @param interstitialAd 插屏广告实例对象
 */
- (void)HZZF_interstitialAdSuccedToLoad:(HZZFAdSDKInterstitialAd *)interstitialAd{
    NSLog(@"%s", __func__);
    // 获取价格，价格上报
    //    NSInteger price = [self.interstitialAd getBidPrice];
    //    [self.interstitialAd sendWinNotice:price];
    // 设置控制器，展示插屏广告
    self.interstitialAd.controller = self;
    [self.interstitialAd show];
}

/**
 HZZFAdSDKIntertitialAd请求失败回调
 
 @param interstitialAd 插屏广告实例对象
 @param error 失败原因
 */
- (void)HZZF_interstitialAdFailedToLoad:(HZZFAdSDKInterstitialAd *)interstitialAd error:(NSError *)error{
    NSLog(@"%s", __func__);
}

/**
 HZZFAdSDKIntertitialAd展示在屏幕内回调
 
 @param interstitialAd 插屏广告实例对象
 */
- (void)HZZF_interstitialAdDidPresent:(HZZFAdSDKInterstitialAd *)interstitialAd{
    NSLog(@"%s", __func__);
}

/**
 HZZFAdSDKIntertitialAd展示在屏幕内失败回调
 
 @param interstitialAd 插屏广告实例对象
 */
- (void)HZZF_interstitialAdFailedToPresent:(HZZFAdSDKInterstitialAd *)interstitialAd error:(NSError *)error{
    NSLog(@"%s", __func__);
}

/**
 HZZFAdSDKIntertitialAd点击回调
 
 @param interstitialAd 插屏广告实例对象
 @param loadingPageURL 广告落地页地址，当渠道为bwt，并且customLoadingPage为YES时有值
 */
- (void)HZZF_interstitialAdDidClick:(HZZFAdSDKInterstitialAd *)interstitialAd loadingPageURL:(NSString *)loadingPageURL{
    NSLog(@"%s", __func__);
}

/**
 HZZFAdSDKIntertitialAd关闭回调
 
 @param interstitialAd 插屏广告实例对象
 */
- (void)HZZF_interstitialAdDidClose:(HZZFAdSDKInterstitialAd *)interstitialAd{
    NSLog(@"%s", __func__);
}

/**
 HZZFAdSDKIntertitialAd展示回调
 
 @param interstitialAd 广告实例
 */
- (void)HZZF_interstitialAdExposure:(HZZFAdSDKInterstitialAd *)interstitialAd{
    NSLog(@"%s", __func__);
}

/**
 HZZFAdSDKIntertitialAd展示上报回调
 
 @param interstitialAd 广告实例
 */
- (void)HZZF_interstitialAdExposureReport:(HZZFAdSDKInterstitialAd *)interstitialAd{
    NSLog(@"%s", __func__);
}


/**
 HZZFAdSDKIntertitialAd点击上报回调
 
 @param interstitialAd 插屏广告实例对象
 */
- (void)HZZF_interstitialAdDidClickReport:(HZZFAdSDKInterstitialAd *)interstitialAd{
    NSLog(@"%s", __func__);
}

/**
 HZZFAdSDKIntertitialAd关闭落地页回调
 
 @param interstitialAd 广告实例
 */
- (void)HZZF_interstitialAdCloseLandingPage:(HZZFAdSDKInterstitialAd *)interstitialAd{
    NSLog(@"%s", __func__);
}
@end
